package com.example.timeemail;


import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.example.timeemail.city.CityFragment;
import com.example.timeemail.home.HomeFragment;
import com.example.timeemail.fragment.MessageFragment;
import com.example.timeemail.fragment.PersonFragment;
import com.example.timeemail.letter.EmailActivity;
import com.example.timeemail.letter.LetterActivity;
import com.example.timeemail.letter.PletterActivity;
import com.example.timeemail.my.AccountActivity;
import com.example.timeemail.my.DriftActivity;
import com.example.timeemail.my.OpinionActivity;
import com.example.timeemail.my.OrdersActivity;
import com.example.timeemail.widget.MainNavigateTabBar;


public class MainActivity extends AppCompatActivity {

    private static final String TAG_PAGE_HOME = "时光漂流";
    private static final String TAG_PAGE_CITY = "时光相册";
    private static final String TAG_PAGE_PUBLISH = "时光信件";
    private static final String TAG_PAGE_MESSAGE = "时光周边";
    private static final String TAG_PAGE_PERSON = "我的";


    private MainNavigateTabBar mNavigateTabBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mNavigateTabBar = (MainNavigateTabBar) findViewById(R.id.mainTabBar);

        mNavigateTabBar.onRestoreInstanceState(savedInstanceState);

        mNavigateTabBar.addTab(HomeFragment.class, new MainNavigateTabBar.TabParam(R.mipmap.comui_tab_home, R.mipmap.comui_tab_home_selected, TAG_PAGE_HOME));
        mNavigateTabBar.addTab(CityFragment.class, new MainNavigateTabBar.TabParam(R.mipmap.comui_tab_city, R.mipmap.comui_tab_city_selected, TAG_PAGE_CITY));
        mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(0, 0, TAG_PAGE_PUBLISH));

        mNavigateTabBar.addTab(MessageFragment.class, new MainNavigateTabBar.TabParam(R.mipmap.comui_tab_message, R.mipmap.comui_tab_message_selected, TAG_PAGE_MESSAGE));
        mNavigateTabBar.addTab(PersonFragment.class, new MainNavigateTabBar.TabParam(R.mipmap.comui_tab_person, R.mipmap.comui_tab_person_selected, TAG_PAGE_PERSON));
    }


    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mNavigateTabBar.onSaveInstanceState(outState);
    }


    public void onClickPublish(View v) {
        Intent intent = new Intent(this, LetterActivity.class);
        startActivity(intent);
    }


    //连接方法
    public void my_1(View view){
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("邀请有礼");
        alert.setIcon(R.drawable.ic_launcher_foreground);
        alert.setMessage("邀请好友可获得TE币，可抵扣现金，您已邀请X位好友，获得XXAE币");
        alert.show();
    }
    public void my_2(View view){
        Intent intent = new Intent(this, AccountActivity.class);
        startActivity(intent);
    }
    public void my_3(View view){
        Intent intent = new Intent(this, OrdersActivity.class);
        startActivity(intent);
    }
    public void my_4(View view){
        Intent intent = new Intent(this, DriftActivity.class);
        startActivity(intent);
    }
    public void my_5(View view){
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("收件箱");
        alert.setIcon(R.drawable.ic_launcher_foreground);
        alert.setMessage("暂无新邮件");
        alert.show();
    }
    public void my_6(View view){
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("寄件箱");
        alert.setIcon(R.drawable.ic_launcher_foreground);
        alert.setMessage("暂无寄邮件");
        alert.show();
    }
    public void my_7(View view){
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("联系我们");
        alert.setIcon(R.drawable.ic_launcher_foreground);
        alert.setMessage("开发者QQ：2045949224，开发者微信：zl_wx_001");
        alert.show();
    }
    public void my_8(View view){
        Intent intent = new Intent(this, OpinionActivity.class);
        startActivity(intent);
    }
    public void my_9(View view){
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("隐私条款");
        alert.setIcon(R.drawable.ic_launcher_foreground);
        alert.setMessage("Time Email用户隐私条款，本软件将始终把用户隐私放在首位，绝不会泄露用户隐私。。。");
        alert.show();
    }
    public void my_10(View view){
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("关于软件");
        alert.setIcon(R.drawable.ic_launcher_foreground);
        alert.setMessage("版本号1.0.0");
        alert.show();
    }
    public void my_11(View view){
        Intent intent = new Intent(this, SigninActivity.class);
        startActivity(intent);
    }
    public void letter_1(View view){
        Intent intent = new Intent(this, EmailActivity.class);
        startActivity(intent);
    }
    public void letter_2(View view){
        Intent intent = new Intent(this, PletterActivity.class);
        startActivity(intent);
    }


    void ToastShow(String context){
        Toast toast = Toast.makeText(this, context, Toast.LENGTH_LONG);
        View view = LayoutInflater.from(this).inflate(R.layout.toast_template,null);
        TextView TxtTaostContext = (TextView)view.findViewById(R.id.TxtTaostContext);
        TxtTaostContext.setText(context);
        toast.setView(view);
        toast.setGravity(Gravity.CENTER,0,0);
        toast.show();
    }
}
